require('../../assets/css/index.less');
require("../../assets/fitness-font/iconfont.css");
require('./sportsRide.less')

// 引入导航
const { showNav, showTopNav } = require('../../utils/nav');
showNav('sports')
showTopNav('sportsride')

// 引入axios
const axios = require('../../utils/axios.js');

// 引入window
const { $, g } = require('../../utils/dom')

$(function () {

    axios.get('/api/exercise').then(res => {
        if (res.data.errno === 0) {
            g('#kilometre').textContent = (res.data.data.sum7Meter / 1000).toFixed(1);
        }
    })

    /**
     * 地图api
     */
    var map = new AMap.Map('container', {
        zoom: 18,//级别
        center: [104.064209, 30.541669],//中心点坐标
        viewMode: '3D'//使用3D视图
    });

    AMap.plugin('AMap.ToolBar', function () {//异步加载插件
        var toolbar = new AMap.ToolBar();
        map.addControl(toolbar);
    });

    g('.go').addEventListener('click', () => {
        g('.mask').style.display = 'flex'
        let time = 3;
        setInterval(() => {
            --time;
            // g('.mask').textContent = time

            if (time < 0) {
                window.location.href = './run.html'
                return
            }
            g('.mask').textContent = time > 0 ? time : 'GO';
        }, 1000)
    })
})